package kr.bos.Subclasses;

import kr.bos.Intro;
import kr.bos.R;
import kr.bos.Framework.BaseActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.Log;
import android.widget.TextView;

/**
 * 바로가기를 바탕화면에 추가하는 테스트 
 * @author baek
 */
public class ShortcutGenerate extends BaseActivity{
	
	private String install_shortcut;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.single_text);
		
		install_shortcut = "com.android.launcher.action.INSTALL_SHORTCUT";

		setupShortcut();
		((TextView)findViewById(R.id.textView1)).setText("END OF PROCESS");
		
	}

	private void setupShortcut() {

		
	        Intent shortcutIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT);
	        shortcutIntent.setClassName(this,Intro.class.getName());
	        shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

		Intent i = new Intent();
	        i.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
	        i.putExtra(Intent.EXTRA_SHORTCUT_NAME, "안녕하소");
	        Parcelable iconResource = Intent.ShortcutIconResource.fromContext(this, R.drawable.icon);
	        i.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource);
	        i.putExtra("duplicate", false);            // // Do not allow duplicate items
	        
	        i.setAction(install_shortcut);
	        sendBroadcast(i);
	}
	
	@Override
	protected void onActivityResult(int requestCode, int resultCode,
			Intent data) {
		// TODO Auto-generated method stub
		Log.e("shortcut",""+resultCode);
		Log.e("shortcut",""+requestCode);
		super.onActivityResult(requestCode, resultCode, data);
	}
}

